import tkinter as tk

# 创建主窗口
window = tk.Tk()
window.title('Chinese Chess Board')

# 设置窗口大小
window.geometry('600x700')

# 创建 Canvas 组件
canvas = tk.Canvas(window, width=600, height=600)
canvas.pack()

# 棋盘参数
square_size = 60
board_size = 9
board_margin = 50

# 绘制棋盘横线
for i in range(board_size + 1):
    start_x = board_margin
    start_y = board_margin + i * square_size
    end_x = board_margin + (board_size - 1) * square_size
    end_y = start_y
    canvas.create_line(start_x, start_y, end_x, end_y, width=2)

# 绘制棋盘竖线
for i in range(board_size):
    start_x = board_margin + i * square_size
    start_y = board_margin
    end_x = start_x
    end_y = board_margin + (board_size - 1) * square_size
    canvas.create_line(start_x, start_y, end_x, end_y, width=2)

# 绘制楚河汉界
river_start_x = board_margin
river_start_y = board_margin + 4 * square_size
river_end_x = board_margin + (board_size - 1) * square_size
river_end_y = river_start_y
canvas.create_rectangle(river_start_x, river_start_y, river_end_x, river_end_y + square_size, fill="lightyellow")

# 绘制九宫格斜线
# 上方九宫格
canvas.create_line(board_margin + 3 * square_size, board_margin, board_margin + 5 * square_size, board_margin + 2 * square_size, width=2)
canvas.create_line(board_margin + 5 * square_size, board_margin, board_margin + 3 * square_size, board_margin + 2 * square_size, width=2)
# 下方九宫格
canvas.create_line(board_margin + 3 * square_size, board_margin + 7 * square_size, board_margin + 5 * square_size, board_margin + 9 * square_size, width=2)
canvas.create_line(board_margin + 5 * square_size, board_margin + 7 * square_size, board_margin + 3 * square_size, board_margin + 9 * square_size, width=2)

# 主窗口循环显示
window.mainloop()
